package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MedicalReportsList;
import com.ruoyi.system.service.IMedicalReportsListService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 体检报告列表Controller
 *
 * @author ruoyi
 * @date 2023-11-15
 */
@RestController
@RequestMapping("/system/list")
public class MedicalReportsListController extends BaseController
{
    @Autowired
    private IMedicalReportsListService medicalReportsListService;

    /**
     * 查询体检报告列表列表
     */
    @PreAuthorize("@ss.hasPermi('system:list:list')")
    @GetMapping("/list")
    public TableDataInfo list(MedicalReportsList medicalReportsList)
    {
        startPage();
        List<MedicalReportsList> list = medicalReportsListService.selectMedicalReportsListList(medicalReportsList);
        return getDataTable(list);
    }

    /**
     * 导出体检报告列表列表
     */
    @PreAuthorize("@ss.hasPermi('system:list:export')")
    @Log(title = "体检报告列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MedicalReportsList medicalReportsList)
    {
        List<MedicalReportsList> list = medicalReportsListService.selectMedicalReportsListList(medicalReportsList);
        ExcelUtil<MedicalReportsList> util = new ExcelUtil<MedicalReportsList>(MedicalReportsList.class);
        util.exportExcel(response, list, "体检报告列表数据");
    }

    /**
     * 获取体检报告列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:list:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(medicalReportsListService.selectMedicalReportsListById(id));
    }

    /**
     * 新增体检报告列表
     */
    @PreAuthorize("@ss.hasPermi('system:list:add')")
    @Log(title = "体检报告列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MedicalReportsList medicalReportsList)
    {
        return toAjax(medicalReportsListService.insertMedicalReportsList(medicalReportsList));
    }

    /**
     * 修改体检报告列表
     */
    @PreAuthorize("@ss.hasPermi('system:list:edit')")
    @Log(title = "体检报告列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MedicalReportsList medicalReportsList)
    {
        return toAjax(medicalReportsListService.updateMedicalReportsList(medicalReportsList));
    }

    /**
     * 删除体检报告列表
     */
    @PreAuthorize("@ss.hasPermi('system:list:remove')")
    @Log(title = "体检报告列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(medicalReportsListService.deleteMedicalReportsListByIds(ids));
    }
}
